		#region Imports
		using System;
		using System.ComponentModel;
		using System.ComponentModel.Design;
		using System.Web.UI;
		using System.Web.UI.Design;
		using System.Web.UI.WebControls;
		using InsightHumans = PHSRAG.Insight21.Humans;  
		#endregion

		namespace PHSRAG.Insight21.InsightWebControls
		{
			/// <summary>
			///  Navigation Bar for CoI Overview Pages
			/// </summary>
			[ToolboxData("<{0}:CoISubNavigationrunat=server />")]
			[Designer(typeof(CoISubModNavigationDesigner), typeof(IDesigner))]
			public class COISubModNavigation: SubNavigation
			{
				#region Constants
				private const string SelectedCoISubModNavigationLinkKey = 
					"SelectedCoISubModNavigationLink_D4C1C328-B720-41a7-80B9-B47607825748";
				#endregion

				#region Instance Variables
				private LinkButton formsLinkButton; //My COI forms List
				#endregion

				#region Implementations for abstract properties and methods from Base Class SubNavigation

				/// <summary>
				/// Create all controls in the CoISubNavigation.
				/// </summary>
				protected override void CreateControls()
				{
					Controls.Clear();

					formsLinkButton = new LinkButton();
					formsLinkButton.CommandName = formsLinkButton.Text = "Forms";
					formsLinkButton.CommandArgument = Utility.Settings.GetKeyValue("SubNavigation.CoI.COIOverviewURL", "");
				}
				/// <summary>
				/// Setup the control tree to reflect the actual (and exact) layout of the controls 
				/// within the CoISubModNavigation.
				/// </summary>
				protected override void GenerateControlTree()
				{
					Table table = new Table();
					Controls.Add(table);
					table.CssClass = "SubModuleSummaryNavigation";
					table.EnableViewState = false;

					TableRow row = new TableRow();
					table.Rows.Add(row);

					TableCell cell = new TableCell();
					row.Cells.Add(cell);
					cell.CssClass = "SubModuleSummaryNavigationFillerCell";
					cell.Controls.Add(new LiteralControl("&nbsp;"));

					cell = new TableCell();
					row.Cells.Add(cell);

					table = new Table();
					cell.Controls.Add(table);

					row = new TableRow();
					table.Rows.Add(row);

					cell = new TableCell();
					row.Cells.Add(cell);

					cell = new TableCell();
					row.Cells.Add(cell);
					cell.Controls.Add(formsLinkButton);

					CreateSelectedLinkAdornments(row);
				}

				/// <summary>
				/// The selected link cell is given a prefix and suffix image as adornments. In addition the background of the
				/// cell is of a different style.
				/// </summary>
				private void CreateSelectedLinkAdornments(TableRow row)
				{
					LinkButton selectedLink = GetSelectedLink();
					if (selectedLink != null)
					{
						foreach (TableCell cell in row.Cells)
						{
							if ((cell.Controls.Count == 1) && (cell.Controls[0] == selectedLink))
							{
								cell.CssClass = "SubModuleNavigationSelectedSummary";

								TableCell adornmentCell = new TableCell();
								adornmentCell.CssClass = "SubModuleNavigationSelectedSummaryAdornment";
								row.Cells.AddAt(row.Cells.GetCellIndex(cell), adornmentCell);

								const string prefixImage = "../Images/Row2_Left.gif";
								System.Drawing.Bitmap bitmap = new System.Drawing.Bitmap(Context.Server.MapPath(prefixImage));
								Image image = new Image();
								image.ImageUrl = prefixImage;
								adornmentCell.Width = bitmap.Width;
								adornmentCell.Controls.Add(image);

								adornmentCell = new TableCell();
								adornmentCell.CssClass = "SubModuleNavigationSelectedSummaryAdornment";
								row.Cells.AddAt(row.Cells.GetCellIndex(cell) + 1, adornmentCell);

								const string suffixImage = "../Images/Row2_Right.gif";
								bitmap = new System.Drawing.Bitmap(Context.Server.MapPath(suffixImage));
								image = new System.Web.UI.WebControls.Image();
								image.ImageUrl = suffixImage;
								adornmentCell.Width = bitmap.Width;
								adornmentCell.Controls.Add(image);

								break;
							}
						}
					}
				}
				/// <summary>
				/// Retrieve the name of the link that was last clicked on.
				/// </summary>
				/// <returns>Reference to the link button corresponding to the clicked link</returns>
				protected override LinkButton GetSelectedLink()
				{
					// Anytime a link is clicked on, the OnBubbleEvent handler stores the name of the link 
					// in the session. Retrieve that name and return the corresponding link button reference.

					object o = Page.Session[SelectedCoISubModNavigationLinkKey];
					if (o != null)
					{
						string commandName = (string)o;
						if (commandName == formsLinkButton.CommandName)
						{
							return formsLinkButton;
						}
					}			
					return formsLinkButton;
				}

				/// <summary>
				/// 
				/// </summary>
				protected override string SelectedSubNavigationLinkKey
				{
					get 
					{
						return SelectedCoISubModNavigationLinkKey;
					}
				}
				/// <summary>
				/// Set the selected link so that on load, the appropriate tab may be shown highlighted. This property is invoked
				/// by pages while vectoring to other pages which host this navigation control.
				/// </summary>
				public string SelectedLink
				{
					set { Page.Session[SelectedSubNavigationLinkKey] = value; }
				}
				#endregion
			}
			
				#region Class CoISubModNavigationDesigner
				/// <summary>
				/// Designer associated with the control.
				/// </summary>
				public class CoISubModNavigationDesigner : ControlDesigner
				{
					#region Overrides
					/// <summary>
					/// Force the control to create its child controls for display at design time.
					/// </summary>
					/// <returns>HTML representation of the control</returns>
					public override string GetDesignTimeHtml()
					{
						((COISubModNavigation)Component).Design();
						return base.GetDesignTimeHtml();
					}
					#endregion
				}
			#endregion
			}
		
